# include <stdio.h>  
# include <stdlib.h>  
# define MAXN 20  
int n,m,good;  
int col[MAXN+1],a[MAXN+1];  
int b[2*MAXN+1],c[2*MAXN+1];  
int main()  
{
  int j;  
  char awn;  
  printf("input n:");scanf("%d",&n);  
  for(j=0;j<=n;j++)a[j]=1;  
  for(j=0;j<=2*n;j++)b[j]=c[j]=1;  
  m=1;col[1]=1;good=1;col[0]=0;  
  do{  
  if (good)  
  if (m==n)  
  {
  printf("lie\thang\n");  
  for (j=1;j<=n;j++) printf("%3d\t%d\n",j,col[j]);  
  scanf("%c",&awn);  
  if (awn=='Q'||awn=='q') exit(0);  
  while (col[m]==n)   
{  
  m--;  
  a[col[m]]=b[m+col[m]]=c[n+m-col[m]]=1;  
  }  
  col[m]++;  
  }  
  else  
  {  
  a[col[m]]=b[m+col[m]]=c[n+m-col[m]]=0;  
  col[++m]=1;  
  }  
  else {  
  while (col[m]==n)
  {  
  m--;  
  a[col[m]]=b[m+col[m]]=c[n+m-col[m]]=1;  
  }  
  col[m]++;  
  }  
  good=a[col[m]]&&b[m+col[m]]&&c[n+m-col[m]];  
  }while (m!=0);  
}
